//
//  MBTwoContentCell.m
//  发布求租
//
//  Created by MB__Lee on 2018/6/7.
//  Copyright © 2018年 MB__Lee. All rights reserved.
//

#import "MBTwoContentCell.h"

@interface MBTwoContentCell()<UITextFieldDelegate>

//标题label  --期望租金 期望面积
@property (weak, nonatomic) IBOutlet UILabel *oneLabel;

// 单位
@property (weak, nonatomic) IBOutlet UILabel *unitLabel;

// *
@property (weak, nonatomic) IBOutlet UILabel *redLabel;

//开始 结束 数值
@property (weak, nonatomic) IBOutlet UITextField *startField;

@property (weak, nonatomic) IBOutlet UILabel *zhiLabel;
@property (weak, nonatomic) IBOutlet UITextField *endField;

@end

@implementation MBTwoContentCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.startField.delegate = self;
    self.endField.delegate = self;
    
    self.startField.tag = 100;
    self.endField.tag = 101;
    
    self.startField.tintColor = MB_mainColor;
    self.endField.tintColor = MB_mainColor;
    
    // Initialization code
}
-(void)setCMModel:(MBCommonCellModel *)CMModel{
    [super setCMModel:CMModel];
    
    //1.隐藏显示*
    if (CMModel.hasX) {
        self.redLabel.hidden  = NO;
    }else{
        self.redLabel.hidden = YES;
    }
    
    //2.期望面积、期望租金
    self.oneLabel.text = CMModel.title;
    
    //3. 至 label
    self.zhiLabel.text = CMModel.middle;
    
    //4. 单位label
    self.unitLabel.text = CMModel.unit;
    
    
}

#pragma mark ----UITextFieldDelegate
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
    
    [textField resignFirstResponder];

    return  YES;
}
-(void)textFieldDidEndEditing:(UITextField *)textField{
    if (textField.tag == 100) {
        self.CMModel.sourceMiddle = textField.text;
    }else if (textField.tag == 101){
        self.CMModel.sourceUnit = textField.text;
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
